<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="common/head.jsp"%>
<div class="right_col" role="main">
	<br /> <br /> <br /> <br /> <br />
	<div class="container">
		<br /> <br /> <br /> <br /> 
		<table class="display" id="example">
			<thead>
				<tr align="center">
					<th>趣事编号</th>
					<th>趣事类型</th>
					<th>发布人</th>
					<th>发布时间</th>
					<th>发布地址</th>
					<th>发布内容</th>
					<th>转发次数</th>
					<th>评论次数</th>
					<th>点赞次数 </th>
					<th>相关操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${newsList}" var="newsList">
					<tr align="center">
						<td>${newsList.sequnce}</td>
						<td>${newsList.type}</td>
						<td>${newsList.userName}</td>
						<td>${newsList.datetime}</td>
						<td>${newsList.address}</td>
						<td>${newsList.content}</td>
						<td>${newsList.forward}</td>
						<td>${newsList.comment}</td>
						<td>${newsList.thumbUp}</td>
						<td>
							<div class="btn-group">
								<button style="height: 30px" type="button"
									class="btn btn-danger">操作</button>
								<button style="height: 30px" type="button"
									class="btn btn-danger dropdown-toggle" data-toggle="dropdown"
									aria-expanded="false">
									<span class="caret"></span> <span class="sr-only">Toggle
										Dropdown</span>
								</button>
								<ul class="dropdown-menu" role="menu" style="margin-left:-40px;">
									<li><a href="javascript:;"
										newsId="${newsList.id}" class="delNews">删除</a></li>
								</ul>
							</div>
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
</div>
<script>
$(document).ready(function() {
	//趣事删除
	$(".delNews").click(function() {
        var obj = $(this);
        var newsId = obj.attr("newsId");
        if (confirm("该趣事涉及色情,低俗,暴力等不良内容吗?")) {
        if (confirm("真的要删除它吗?")) {
            $.ajax({
                type: "GET",
                url: "<%=basePath%>news/delNews",
                data: {
                    "newsId": newsId,
                },
                dataType: "json",
                success: function(data) {
                    if (data.result == "true") {
                        alert("亲,恭喜您删除成功了");
                        window.location.href = "<%=basePath%>news/showNews";
															} else{
																alert("对不起，删除失败了");
															}
														},
														error : function(
																data) {
															alert("对不起，删除失败了");
														}
													});
										}
        }
	});
});
</script>
<!--dataTables-->
<script charset="utf-8" type="text/javascript">
	$(document).ready(function() {
		$('#example').dataTable();
	});
</script>
<script type="text/javascript">
$('#example').removeClass('display').addClass('table table-striped table-bordered');
</script>
<!--dataTables-->
<%@ include file="common/foot.jsp"%>